package ${packagePrefix}.${domainObjectName?lower_case}.client.dto.excel;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.*;
import com.alibaba.excel.enums.poi.BorderStyleEnum;
import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
import com.alibaba.excel.enums.poi.VerticalAlignmentEnum;
import lombok.Data;

<#if generateComments>
/**
 * ${domainObjectName}Excel导入导出数据模型
 * <p>
 * 用于Excel文件的导入和导出操作，包含必要的Excel注解配置
 * </p>
 *
 * @author Auto Generated
 */
</#if>
@Data
@HeadStyle(fillForegroundColor = 9, // 浅蓝色表头
           borderTop = BorderStyleEnum.THIN, borderBottom = BorderStyleEnum.THIN,
           borderLeft = BorderStyleEnum.THIN, borderRight = BorderStyleEnum.THIN)
@HeadFontStyle(fontHeightInPoints = 12, bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.CENTER,
              verticalAlignment = VerticalAlignmentEnum.CENTER,
              borderTop = BorderStyleEnum.THIN, borderBottom = BorderStyleEnum.THIN,
              borderLeft = BorderStyleEnum.THIN, borderRight = BorderStyleEnum.THIN,
              wrapped = true) // 自动换行
@ContentFontStyle(fontHeightInPoints = 11)
public class ${domainObjectName}ExcelDTO {

    /**
     * 导入模板示例文件名
     */
    public static final String IMPORT_TEMPLATE_NAME = "${domainObjectName}导入模板";
    
    /**
     * 导出文件名
     */
    public static final String EXPORT_FILE_NAME = "${domainObjectName}数据";

    @ExcelProperty("序号")
    private Integer rowIndex;
    
<#list fields as field>
    <#if field.name != "id" && field.name != "createdTime" && field.name != "updatedTime" && field.name != "createdBy" && field.name != "updatedBy" && field.name != "isDeleted">
    <#if field.excelTitle??>
    @ExcelProperty("${field.excelTitle}")
    <#else>
    @ExcelProperty("${field.comment}")
    </#if>
    <#if field.javaType == "Date" || field.javaType == "LocalDate" || field.javaType == "LocalDateTime">
    @com.alibaba.excel.annotation.format.DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    </#if>
    <#if field.javaType == "BigDecimal">
    @com.alibaba.excel.annotation.format.NumberFormat("#.##")
    </#if>
    private ${field.javaType} ${field.name};
    
    </#if>
</#list>

    /**
     * 构建导入模板数据
     * 
     * @return 导入模板数据列表
     */
    public static List<${domainObjectName}ExcelDTO> buildImportTemplateData() {
        ${domainObjectName}ExcelDTO template = new ${domainObjectName}ExcelDTO();
        template.setRowIndex(1);
        <#list fields as field>
        <#if field.name != "id" && field.name != "createdTime" && field.name != "updatedTime" && field.name != "createdBy" && field.name != "updatedBy" && field.name != "isDeleted">
        <#if field.javaType == "String">
        template.set${field.name?cap_first}("示例${field.comment}");
        <#elseif field.javaType == "Integer" || field.javaType == "Long">
        template.set${field.name?cap_first}(1);
        <#elseif field.javaType == "BigDecimal">
        template.set${field.name?cap_first}(new java.math.BigDecimal("0.00"));
        <#elseif field.javaType == "Boolean">
        template.set${field.name?cap_first}(true);
        <#elseif field.javaType == "Date">
        template.set${field.name?cap_first}(new Date());
        <#elseif field.javaType == "LocalDate">
        template.set${field.name?cap_first}(java.time.LocalDate.now());
        <#elseif field.javaType == "LocalDateTime">
        template.set${field.name?cap_first}(java.time.LocalDateTime.now());
        </#if>
        </#if>
        </#list>
        
        return Collections.singletonList(template);
    }
    
    <#if hasStatusField>
    /**
     * 获取状态显示文本
     * 
     * @param status 状态码
     * @return 状态显示文本
     */
    public static String getStatusText(Integer status) {
        if (status == null) {
            return "";
        }
        
        switch (status) {
            case 0:
                return "禁用";
            case 1:
                return "启用";
            <#if specialRequirements?? && specialRequirements?contains("审批")>
            case 2:
                return "待审核";
            case 3:
                return "已拒绝";
            </#if>
            default:
                return "未知状态(" + status + ")";
        }
    }
    </#if>
} 